import request from '@/utils/request'

// 创建支付订单
export function createPayment(orderNo) {
  return request({
    url: `/api/payments/orders/${orderNo}`,
    method: 'post'
  })
}

// 查询支付状态
export function queryPaymentStatus(paymentId) {
  return request({
    url: `/api/payments/${paymentId}/status`,
    method: 'get'
  })
}

// 计算分期金额
export function calculateInstallment(params) {
  return request({
    url: '/api/payments/installment/calculate',
    method: 'get',
    params
  })
}

// 检查分期资格
export function checkInstallmentEligibility(params) {
  return request({
    url: '/api/payments/installment/check',
    method: 'get',
    params
  })
}

// 获取支付订单详情
export function getPaymentOrder(orderId) {
  return request({
    url: `/api/payments/${orderId}`,
    method: 'get'
  })
}

// 获取支付方式列表
export function getPaymentMethods() {
  return request({
    url: '/api/payments/methods',
    method: 'get'
  })
}

// 确认支付
export function confirmPayment(orderId, method) {
  return request({
    url: `/api/payments/${orderId}/confirm`,
    method: 'post',
    data: { method }
  })
}

// 取消支付
export function cancelPayment(orderId) {
  return request({
    url: `/api/payments/${orderId}/cancel`,
    method: 'post'
  })
}

// 获取支付历史
export function getPaymentHistory(params) {
  return request({
    url: '/api/payments/history',
    method: 'get',
    params
  })
} 